home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / modula2 / 189 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.8 KB

  1. Path: fourier.newcastle.edu.au!peter
  2. From: peter@fourier.newcastle.edu.au (Peter Moylan)
  3. Newsgroups: comp.lang.modula2
  4. Subject: Re: Modula2 for C programmers?
  5. Date: 28 Jan 1996 23:55:18 GMT
  6. Organization: The University of Newcastle
  7. Message-ID: <4eh2d6$18d@seagoon.newcastle.edu.au>
  8. References: <erico-1801961940460001@infinitehell.cnmat.berkeley.edu> <4dqusf$d7k@weck.brokersys.com> <DLIGLJ.FDE@nyongwa.montreal.qc.ca> <4du11j$l31@weck.brokersys.com> <4e3t1f$d5q@seagoon.newcastle.edu.au> <4e5b5u$7s5@weck.brokersys.com> <822561600snz@nezumi.demon.co.uk>
  9. Reply-To: peter@tesla.newcastle.edu.au
  10. NNTP-Posting-Host: fourier.newcastle.edu.au
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. When I first came to Modula-2 I used BITSET for things like
  14. manipulating I/O ports; I imagine that Wirth had things like that
  15. in mind when he put BITSET into the language.  I've since
  16. switched to other methods - in fact, I almost never use BITSET
  17. now, even though most of my programming is of the "down to the
  18. bare metal" variety - because of two problems:
  19.  
  20. 1. Size: is a BITSET 8 bits wide, or 16, or 32, or something else?
  21.    You might think that this doesn't matter if the software is
  22.    for a very specific hardware configuration; but the fact is
  23.    that the width of a BITSET varies even between two different
  24.    compilers for the same machine.
  25. 2. Bit numbering: is bit 0 the leftmost bit, or the rightmost?
  26.    People have been arguing over which of these two conventions
  27.    is "best" for years, and neither camp has dominated over the
  28.    other.  (Some people even use big-endian at the bit level
  29.    combined with little-endian at the byte level, or vice versa.)
  30.    Whichever convention you use, you'll soon find a compiler
  31.    writer who prefers the opposite.
  32.  
  33. When I used FTL Modula-2 for the PC, one of the claimed features
  34. of the compiler was that "unlike other compilers, this compiler
  35. uses the correct numbering for bits in a BITSET".  The author's
  36. definition of "correct" was, as nearly as I could judge, the
  37. numbering system defined in the hardware documentation for the
  38. 6502 microprocessor.  One consequence of this was that the bits
  39. in a byte were numbered 8..15 (i.e. bits 0..7 didn't exist).
  40. Well, the author was entitled to his opinion, but it did make
  41. him inconsistent with most other compilers for the PC.
  42.  
  43. The ISO M2 standard does, I think, dictate a little-endian
  44. ordering for BITSET.  (That's from memory; I've forgotten which
  45. section I should look up.)  But that doesn't completely resolve
  46. the problems that arise when, for example, you upgrade your
  47. PC compiler from 16-bit to 32-bit support.
  48.  
  49. I remain convinced that BITSET should have been defined in
  50. SYSTEM, so that it was clearly labelled as non-portable.
  51.  
  52. --
  53. Peter Moylan                       peter@ee.newcastle.edu.au
  54.                            ftp://ee.newcastle.edu.au/pub/www/Moylan.html
  55.